import { createStore } from "vuex";
import { ipcRenderer } from "electron";
const setting = ipcRenderer.sendSync("getUserSetting", "asd");
export default createStore({
  state: {
    maximize: false,
    uiText: require(`../language/${setting.language}.js`).default,
    language: setting.language,
    menuCollapse: false,
    theme: setting.theme ? setting.theme : "light",
  },
  mutations: {
    maximize(state, payload) {
      state.maximize = payload;
    },
    menuCollapse(state, payload) {
      state.menuCollapse = payload;
    },
    language(state, payload) {
      state.language = payload;
      state.uiText = require("../language/" + payload + ".js").default;
      setting.language = payload;
      ipcRenderer.send("setUserSetting", setting);
    },
    theme(state, payload) {
      state.theme = payload;
      setting.theme = payload;
      ipcRenderer.send("setUserSetting", setting);
    },
  },
  actions: {},
  modules: {},
});
